import UIKit
import CoreML
import Vision
import CoreImage

class ShinkaiStyleProcessor: ImageProcessor {
    private let model: AnimeGANv3_Shinkai_37
    
    init() throws {
        self.model = try AnimeGANv3_Shinkai_37()
    }
    
    func process(image: UIImage) async throws -> UIImage {
        // 1. 调整图片尺寸为 512x512，保持宽高比
        let targetSize = CGSize(width: 512, height: 512)
        let resizedImage = try await resizeImage(image, to: targetSize)
        
        // 2. 转换为 CVPixelBuffer
        let buffer = try createPixelBuffer(from: resizedImage)
        
        // 3. 创建模型输入并进行推理
        let modelInput = AnimeGANv3_Shinkai_37Input(AnimeGANv3_input: buffer)
        let prediction = try model.prediction(input: modelInput)
        
        // 4. 处理输出
        return try createOutputImage(from: prediction.image)
    }
} 